package com.class05.header6;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @ClassDescription:
 * 获取请求头
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2023/12/5 9:37
 */
@Controller
@RequestMapping("header")
@ResponseBody
public class HeaderController {
    @GetMapping("getHeader")
//    @RequestHeader 批注将请求标头绑定到控制器中的方法参数。
    public String data(@RequestHeader("Host") String host,
                       @RequestHeader("Accept") String accept){
        System.out.println("host = " + host + ", accept = " + accept);
        return "host = " + host + ", accept = " + accept;
    }
}
